<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\View;
class Mail extends Index
{
	public function __construct(Request $request)
	{
		parent::__construct($request);
	}
	/**
    * 站内信
    */
    public function mailsubmit(){
    	$file = request()->file('mailphoto');
    	$data['mailcontent']=input('post.mailcontent');
		$data['mailtitle']=input('mailtitle');
		$data['addtime']=time();
		$data['userid']=session('userid');
		$data['mailphoto']='';
    	if($file){
    		$info = $file->validate(['size'=>2*1024*1024,'ext'=>'jpg,png,gif'])->move(ROOT_PATH . 'public' . DS . 'uploads/xiangce');
    		if($info){
    			$data['mailphoto']='/public/uploads/xiangce/'.date("Ymd").'/'.$info->getFilename();
    		}
    	}
    	$mail=Db::name('mail')->insertGetId($data);
    	if($mail){
    		jsBack('提交成功','/api/index/userlist');
    	}else{
    		jsBack('提交失败');
    	}
    }
}